package org.wzy.xmlg_backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.wzy.xmlg_backend.entity.Emp;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper extends BaseMapper<Emp> {
    @Select("SELECT CASE gender WHEN 1 THEN '男' WHEN 2 THEN '女' END AS gender, COUNT(*) AS count FROM emp GROUP BY gender")
    List<Map<String, Object>> countByGender();

    @Select("SELECT CASE job WHEN 1 THEN '班主任' WHEN 2 THEN '讲师' WHEN 3 THEN '学工主管' WHEN 4 THEN '教研主管' WHEN 5 THEN '咨询师' END AS jobName, COUNT(*) AS count FROM emp GROUP BY job")
    List<Map<String, Object>> countByJob();

    @Select("SELECT d.name AS deptName, COUNT(e.id) AS count FROM emp e JOIN dept d ON e.dept_id = d.id GROUP BY d.name")
    List<Map<String, Object>> countByDept();

    @Select("SELECT YEAR(entrydate) AS year, COUNT(*) AS count FROM emp GROUP BY YEAR(entrydate) ORDER BY year")
    List<Map<String, Object>> countByEntryYear();
}